/**
 * Copyright (c) 2013 Mark Tielemans
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * DISCLAIMER
 * This software is provided "as is" and any expressed or implied warranties, including, but not limited to, the implied warranties of 
 * merchantability and fitness for a particular purpose are disclaimed. In no event shall the regents or contributors be liable for any 
 * direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute 
 * goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in 
 * contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if 
 * advised of the possibility of such damage.
 */
package nl.marktielemans.easydb.connection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import nl.marktielemans.easydb.DatabaseVendor;

/**
 * Contains methods for database connection, to be implemented for each {@link DatabaseVendor}.
 * 
 * @author Mark Tielemans
 * @since 1.0
 * @version 1.0
 */
public interface DatabaseConnector {
	/**
	 * Execute a query statement that returns a {@link ResultSet}.
	 * @param query statement to be executed
	 * @return resultset resulting from query execution
	 * @throws SQLException
	 */
	public ResultSet query(String query) throws SQLException;
	
	/**
	 * Execute a query statement that returns nothing, i.e. an <code>INSERT</code>, <code>UPDATE</code> 
	 * or <code>DELETE</code> statement.
	 * @param query statment to be executed
	 * @throws SQLException
	 */
	public void update(String query) throws SQLException;
	
	/**
	 * Connect to the database to probe its availability or execute statements manually. It is not 
	 * required to call this method before executing a statement using this connector.
	 * @return an open database connection
	 * @throws SQLException
	 */
	public Connection getConnection() throws SQLException;
}
